<%
	var Stream=Class.create()
		Stream.prototype=
		{
			initialize:function($options)
			{
				this.object=Server.CreateObject('ADODB.Stream');
				this.result=null;
				if(arguments.length!=0)
				{
					/* 声明属性 */
					this.path=$options.path;
					this.charset=($options.charset||'UTF-8');
					this.type=($options.type||adTypeText);
					this.mode=($options.mode||adModeReadWrite);
					this.position=($options.position||0);
					this.lineseparator=($options.lineseparator||adCRLF);
					this.isopen=($options.isopen==false) ? false:true;
					this.isread=($options.isread==true) ? true:false;										
					
					/* 构造对象 */
					try
					{
						if(this.isopen==true)
						{
							if(this.path==undefined) throw 'Path error';
							
							this.object.Type=this.type;
							this.object.Charset=this.charset;
							this.object.Mode=this.mode;		
							
							this.object.Open();
							
							this.object.Position=this.position;
							this.object.LoadFromFile(this.path);
							if(this.isread==true) 
								this.result=(this.object.Type==adTypeText)?this.object.ReadText():this.object.Read();
						}
					}
					catch(e)
					{
						if(e=='Path error')
							throw new Error(cusErrors_0040_ADO$Stream);
						else 
						{
							if(e!=cusFrameworkDo$Break&&Object.varType(e)!='string')							
								throw e;
							else
								throw new Error(e);
						}						
					}
				}
				
			},			
			get:function($property)
			{
				if(($property in this.object)==false)		
					throw new Error(cusErrors_0099_ADO$Global);
					
				$property=($property.toLowerCase());
				if($property in this.object) this[$property]=this.object[$property];				
				return this.object[$property];
			},			
			set:function($property,$value)
			{
				if(($property in this.object)==false)
					throw new Error(cusErrors_0099_ADO$Global);
					
				$property=($property.toLowerCase());				
				this[$property]=$value;
				return this.object[$property]=$value;
			},
			cancel:function()
			{
				this.object.Cancel();
			},			
			write:function($buffer)
			{
				this.object.write($buffer);
			},
			writeText:function($data,$options)
			{
				this.object.writeText($data,$options);
			},
			copyTo:function($destStream,$numChars)
			{
				this.object.CopyTo($destStream,$numChars);
			},
			flush:function($destStream,$numChars)
			{
				this.object.flush();
			},
			loadFromFile:function($fileName)
			{
				this.object.loadFromFile($fileName);
			},
			read:function($numBytes)
			{
				return this.object.read($numBytes||-1);
			},
			readText:function($numChars)
			{
				return this.object.readText($numChars||-1);
			},
			saveToFile:function($options,$filename)
			{
				$filename=($filename||this.path);
				this.object.SaveToFile($filename,$options||2);
			},
			skipLine:function()
			{
				this.object.SkipLine();		
			},
			setEOS:function($position)
			{
				if(isNaN($position)==false) this.object.Position=$position;
				this.object.SetEOS();				
			},
			stat:function($statStg,$statFlag)
			{
				this.object.Stat($statStg,$statFlag);
			},			
			close:function()
			{
				try
				{
					this.object.Close(),this.object=null;				
				}
				catch(e)
				{}
			}			
		};		
%>